/**
 * 
 * @Project le cOeur - Data Virtualization
 * @Date 08.12.2012
 * @Author Aebi Pascal, Kocher Marc
 * @School BFH-TI Biel, Bachelor Thesis
 *
 */

package main.framework.representation;

import main.framework.exception.RepresentationCreationException;
import main.framework.http.ContentType;
import main.framework.http.MessageBody;
import main.framework.resource.ResourceData;

/**
 * This abstract class is the base for all kind of representation creator classes.
 */
public abstract class RepresentationCreator {

	protected ContentType contentType;
	
	/**
	 * Creates a representation creator for the given content type.
	 * 
	 * @param contentType The desired content type for the representations to be created by the representation creator.
	 */
	public RepresentationCreator(ContentType contentType) {
		this.contentType = contentType;
	}
	
	/**
	 * Gets the content type of the representations created by the representation creator.
	 * 
	 * @return The content type of the representations created by the representation creator.
	 */
	public ContentType getContentType() {
		return this.contentType;
	}
	
	/**
	 * Creates a representation based on a data string.
	 * 
	 * @param data The data which should be converted to a representation.
	 * @return The message body which contains the created representation and the corresponding content type.
	 * @throws RepresentationCreationException If a representation creation error occurs.
	 */
	public abstract MessageBody createRepresentation(String data) throws RepresentationCreationException;
	
	/**
	 * Creates a representation based on a resource data object.
	 * 
	 * @param resourceData The resourceData object which contains the data to be converted to a representation.
	 * @return The message body which contains the created representation and the corresponding content type.
	 * @throws RepresentationCreationException If a representation creation error occurs.
	 */
	public abstract MessageBody createRepresentation(ResourceData resourceData) throws RepresentationCreationException;
	
}
